nasapower packageThis package aims at making it quick and easy to automate downloading NASA POWER(Prediction of Worldwide Energy Resource) global meteorology, surface solar energy and climatology data in your R session as a tidy data frame for analysis and use in modelling or other purposes using get_power().
nasapower packageYou can install the packagefrom either CRAN using:
install.packages("nasapower")
or by using the devtools package directly from github using the following code:
if (!require(devtools)) {
install.packages("devtools")
}
devtools::install_github("ropensci/nasapower")
library(nasapower)
get_power() to fetch dataThe get_power() function has five arguments and returns a data frame with a metadata header in the current R session. It has the following arguments:
Community: It can be passed with either “AG”, “SB”, or “SSE”.
AG: provides access to the agroclimatology archive, which contains industry-friendly parameters for input to crop models.
SB: provides access to the sustainable buildings archive, which contains parameters for the building community.
SSE: provides access to the renewable energy archive, which contains parameters very specific to assist in the design of solar and wind powered renewable energy systems.
temporal_average: supported values are “DAILY”, “INTERANNUAL”, “CLIMATOLOGY”.
DAILY : the daily average of pars by day, month and year.
INTERANNUAL: the monthly average of pars by year.
CLIMATOLOGY: the monthly average of pars at the surface of the earth for a given month averaged for that month over the 30 year period.
lonlat:
For Single point: supply a length-two numeric vector giving the decimal degree longitude an dlatitude in that order for the data to download.
For regional coverage: supply a length-four numeric as lower left(lon,lat) and upper right(lon,lat) coordinates as lonlat = c(xmin,ymin,ymax,ymax)
For global coverage: to get globval coverage for CLIMATOLOGY, supply “GLOBAL” while also specifying “CLIMATOLOGY” for the argument temporla_average.
dates: If only one date is provided, it will be treated as both the start and the end date and only a day’s values will be returned.
When the temporal_average is set to “INTERANNUAL”, use only two year values, eg, dates = c(1983,2010).
This argument should not be used when temporal_average is set to “CLIMATOLOGY”.
To know the different weather values from POWER provided within this function type ?get_power, and in the arguments section, click on the highlighted parameters, which goes to a page which has all the available parameters. For rainfall, we use the “PRECTOT”.
data <- get_power(community = "SSE",
lonlat = c(134.489563,-25.734968),
dates = c("2000-01-01","2000-05-01"),
temporal_average = "DAILY",
pars = "PRECTOT")
data %>% datatable(extensions = c('Scroller','FixedColumns'), options = list(
deferRender = TRUE,
scrollY = 350,
scrollX = 350,
dom = 't',
scroller = TRUE,
fixedColumns = list(leftColumns = 3)
))
daily_area <- get_power(community = "AG",
lonlat = c(150.5, -28.5 , 153.5, -25.5),
pars = "PRECTOT",
dates = c("2004-09-19","2004-09-29"),
temporal_average = "DAILY")
daily_area %>% datatable(extensions = c('Scroller','FixedColumns'), options = list(
deferRender = TRUE,
scrollY = 350,
scrollX = 350,
dom = 't',
scroller = TRUE,
fixedColumns = list(leftColumns = 3)
))
global data are only available for the climatology temporal_average like we discussed earlier, setting these arguments as such will fetch the global values.
climate_avg <- get_power(community = "AG",
pars = "PRECTOT",
lonlat = "GLOBAL",
temporal_average = "CLIMATOLOGY"
)
climate_avg %>% datatable(extensions = c('Scroller','FixedColumns'), options = list(
deferRender = TRUE,
scrollY = 350,
scrollX = 350,
dom = 't',
scroller = TRUE,
fixedColumns = list(leftColumns = 3)
))